how to handle array index out of bound exception in java